//
//  ChooseHotViewController.m
//  pushNewsManager
//
//  Created by Jobs on 8/25/17.
//  Copyright © 2017 com.Iori. All rights reserved.
//

#import "ChooseHotViewController.h"
#import "GetHotPointApi.h"
#import "Header.h"
#import "HotSpotEntity.h"

@implementation ChooseHotViewController

-(void)viewDidLoad
{
    [super viewDidLoad];
    WS(weakSelf);
    [self.tableView addPullToRefreshWithActionHandler:^{
        GetHotPointApi *api = [GetHotPointApi new];
        api.admin_id = [UserInfo sharedUser].admin.admin_id;

        [api startWithCompletionBlockWithSuccess:^(YTKBaseRequest *request)
        {
            [weakSelf.tableView.pullToRefreshView stopAnimating];
            if([IoriJsonHelper getErrorCode:request] == 100)
            {
                weakSelf.dropDownDataSource = [NSArray yy_modelArrayWithClass:[HotSpotEntity class] json:[IoriJsonHelper getDictForKey:@"hot" fromDict:request.responseJSONObject]];
                [weakSelf.tableView reloadData];
            }
            else
            {
                
            }
        } failure:^(YTKBaseRequest *request) {
            [weakSelf.tableView.pullToRefreshView stopAnimating];
        }];
    }];
    
    [weakSelf.tableView triggerPullToRefresh];
}

@end
